//
//  VipCardRecordView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/11/1.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "VipCardRecordView.h"

@implementation VipCardRecordView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        
        /**
         余额
         */
        UILabel *balanceCountLabel = [[UILabel alloc] init];
        balanceCountLabel.font = [UIFont fontWithName:@"Helvetica" size:35];
        balanceCountLabel.textColor = CSColorFromRGB(0x212121);
        balanceCountLabel.text = @"318";
        [self addSubview:balanceCountLabel];
        self.balanceCountLabel = balanceCountLabel;
        
        /**
         余额
         */
        UILabel *balanceLabel = [[UILabel alloc] init];
        balanceLabel.font = SmallFont;
        balanceLabel.text = @"余额(元)";
        balanceLabel.textColor = CSColorFromRGB(0xb3b3b3);
        [self addSubview:balanceLabel];
        self.balanceLabel = balanceLabel;
        
        UIView *backGroundView = [[UIView alloc] init];
        backGroundView.backgroundColor = BackGroundColor;
        [self addSubview:backGroundView];
        self.backGroundView = backGroundView;
        
        UILabel *timeLabel = [[UILabel alloc] init];
        timeLabel.font = [UIFont systemFontOfSize:17.0];
        timeLabel.textColor = CSColorFromRGB(0x808080);
        timeLabel.text = @"2017-11";
        [self addSubview:timeLabel];
        self.timeLabel = timeLabel;
        
        UIButton *timeBtn = [[UIButton alloc] init];
        [timeBtn setImage:@"carddetail_icon_month"];
        [self addSubview:timeBtn];
        self.timeBtn = timeBtn;
        
        UILabel *consumeLabel = [[UILabel alloc] init];
        consumeLabel.font = MidFont;
        consumeLabel.textColor = CSColorFromRGB(0x333333);
        consumeLabel.text = @"消费  ￥3731.89";
        [self addSubview:consumeLabel];
        self.consumeLabel = consumeLabel;
        
        UILabel *chargeLabel = [[UILabel alloc] init];
        chargeLabel.font = MidFont;
        chargeLabel.textColor = CSColorFromRGB(0x333333);
        chargeLabel.text = @"充值  ￥3731.89";
        [self addSubview:chargeLabel];
        self.chargeLabel = chargeLabel;
        
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = LineBackGroundColor;
        [self addSubview:lineView];
        self.lineView = lineView;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    /**
     余额
     */
    [self.balanceCountLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self).offset(40);
        
        make.centerX.mas_equalTo(self);
        
    }];
    
    /**
     余额
     */
    [self.balanceLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.mas_equalTo(self);
        
        make.top.mas_equalTo(self.balanceCountLabel.mas_bottom).offset(10);
    }];
    
    [self.backGroundView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.balanceLabel.mas_bottom).offset(40);
        
        make.left.width.mas_equalTo(self);
        
        make.height.mas_equalTo(40);
    }];
    
    [self.timeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self).offset(15);
        
        make.centerY.mas_equalTo(self.backGroundView);
    }];
    
    [self.timeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self).offset(-15);
        
        make.centerY.mas_equalTo(self.backGroundView);
    }];
    
    [self.consumeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self).offset(15);
        
        make.top.mas_equalTo(self.backGroundView.mas_bottom).offset(20);
        
        make.bottom.mas_equalTo(self).offset(-20);
    }];
    
    [self.chargeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.consumeLabel.mas_right).offset(15);
        
        make.centerY.mas_equalTo(self.consumeLabel);
    }];
    
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.mas_equalTo(self);
        
        make.left.mas_equalTo(self).offset(15);
        
        make.right.mas_equalTo(self).offset(-15);
        
        make.height.mas_equalTo(1);
    }];
}

@end
